<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="/js/jquery.form.min.js"></script>


</head>
<body>

<form id="uploadForm" action="demo.jsp" enctype="multipart/form-data" method="post">
    <input id="upfile" type="file" name="upfile">
    <input id="questionId" type="text" name="questionId" value="69">
    <input type="button" value="导入" id="upLoadPayerCreditInfoExcel" name="btn">
</form>

<script type="text/javascript">
     $('#upLoadPayerCreditInfoExcel').click(function(){

     var cacheVersion=$("#cacheVersion").val();
         var contextRoot = /*[[@{/}]]*/ ''


         console.info(contextRoot);

         $("#uploadForm").ajaxSubmit({
             success: function (data) {
                 alert(data.url);
             },
             error: function (error) { alert(error); },
             url: contextRoot+'/question/checkResult', /*设置post提交到的页面*/
             type: "post", /*设置表单以post方法提交*/
             dataType: "json" /*设置返回值类型为文本*/
         });


     });
     //JS校验form表单信息
     function checkData(){
         console.log("11111111111");
     var fileDir = $("#upfile").val();
     var suffix = fileDir.substr(fileDir.lastIndexOf("."));
     if("" == fileDir){

     alert("选择需要导入的Excel文件！");
     return false;
     }
     if(".xls" != suffix && ".xlsx" != suffix ){
     alert("选择Excel格式的文件导入！");
     return false;
     }
     return true;
     }
 </script>
</body>
</html>